<template>
  <div class="item item-1d2" data-type="input-number" v-bind:class="[('w'+obj.property.selfWidth)]">
    <div class="hd" v-bind:class="[('i'+obj.property.titleWidth+'d6')]">
      <label class="tit">{{obj.property.title}}</label>
      <span class="required" v-show="obj.property.required">*</span>
      <span class="block muted">{{obj.property.intro}}</span>
      <v-handle v-bind:handle="obj.handle"></v-handle>
    </div>
    <div class="bd hasunit" v-bind:class="[('i'+(obj.property.titleWidth==6?6:6-obj.property.titleWidth)+'d6')]">
      <!--<input v-bind:placeholder="obj.property.placeholder">
      <span class="type">{{obj.property.numberOption.unit}}</span>-->
      <el-tooltip placement="top" :disabled="disabledTip">
        <div slot="content">如此处仅允许填写填写小数点后{{obj.property.numberOption.decimal}}位，请重新填写。</div>
        <el-input v-if="obj.property.numberOption.limitValue" @change="input_change" :min="obj.property.numberOption.min" :max="obj.property.numberOption.max" type="number" :placeholder="obj.property.placeholder" v-model="obj.value">
          <template slot="append">{{obj.property.numberOption.unit}}</template>
        </el-input>
        <el-input v-if="obj.property.numberOption.limitValue==false" @change="input_change" type="number" :placeholder="obj.property.placeholder" v-model="obj.value">
          <template slot="append">{{obj.property.numberOption.unit}}</template>
        </el-input>
      </el-tooltip>
    </div>
  </div>
</template>
<script>
export default {
  props: ['obj'],
  data:function(){
    return {
      disabledTip:this.obj.property.numberOption.limitDecimal
    }
  },
  methods:{
    input_change:function(value){
      
      if(this.obj.property.numberOption.limitDecimal){
        var decimal = this.obj.property.numberOption.decimal
        if(value.toString().indexOf(".")>0){
          var decimalLen = value.toString().split(".")[1].length
          if(decimalLen>decimal){
            this.obj.value=""
            this.disabledTip=false
          }else{
            this.disabledTip=true
          }
        }
      } 
      //数字区间判断
      if(this.obj.property.numberOption.limitValue){
        if(value<this.obj.property.numberOption.min || value>this.obj.property.numberOption.max){
          this.obj.value=""
        }
      }
      
    }
  }
}
</script>
